<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script>
	//数组的排序
	var arr=[234,65,734,234,6,8,32];
	
	function order(arr,type){
		if(typeof arr!=='object'){
			return;	
		};		
		
		
		for(var i=0;i<arr.length;i++){
			for(var j=i+1;j<arr.length;j++){
				if(type==1){
					if(arr[i]>arr[j]){
						var temp=arr[i];
						arr[i]=arr[j];
						arr[j]=temp;	
					};
				}else{
					if(arr[i]<arr[j]){
						var temp=arr[i];
						arr[i]=arr[j];
						arr[j]=temp;	
					};
				}
			};	
		};
		return arr
	};
	alert(order(arr,1))
</script>
</body>
</html>
